﻿using UnityEngine;
using System.Collections;

public class EnemyShootingBullet : MonoBehaviour 
{

	public GameObject m_EnemyBullet;
	public float m_Speed;
	public float m_Time = 3;
	public Transform m_Target;
	
	// Use this for initialization
	void Start () 
	{
	
	}
	// Update is called once per frame
	void Update () 
	{
		EnemyShooting();
	}
	void EnemyShooting()
	{
		GameObject enemyBulletShot;
		Bullet enemyBullet;
		float cooldown = 0;
		float time = 3; 
		float delay = 5;
		
		if (cooldown > 0)
		{
			cooldown -=Time.deltaTime;
			
		}
		else
		{
			enemyBulletShot = Instantiate(m_EnemyBullet, new Vector3(transform.position.x, transform.position.y, transform.position.z), Quaternion.identity)as GameObject;
			enemyBullet = enemyBulletShot.GetComponent<Bullet>();
			enemyBullet.target = "Player";
			transform.position = new Vector3(m_Speed*Time.deltaTime, 0, 0);
			cooldown = time;
		}
	}
}
